package com.guoheng.hazard.sys.controller.hazard;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.hazard.KeyRegulatoryChemicalInsertDTO;
import com.guoheng.hazard.sys.model.dto.hazard.KeyRegulatoryChemicalUpdateDTO;
import com.guoheng.hazard.sys.service.hazard.KeyRegulatoryChemicalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 类功能描述:　KeyRegulatoryChemicalController
 *
 * @author fbl
 * @date 2019-11-13 07:54
 */
@RestController
@Validated
@Api(value = "重点监管危险化学品信息")
public class KeyRegulatoryChemicalController {

    @Resource
    KeyRegulatoryChemicalService keyRegulatoryChemicalService;

    @ApiOperation(value = "查询企业重点监管危险化学品信息表")
    @GetMapping(value = "data/major/hazard/chemicals")
    public Result getChemicals(String entprName,String productName,Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return keyRegulatoryChemicalService.getChemicals(entprName,productName,entprId,pageNum,pageSize);
    }

    @ApiOperation(value = "修改企业重点监管危险化学品信息表")
    @PutMapping(value = "data/major/hazard/chemicals")
    public Result updateChemicals(@RequestBody KeyRegulatoryChemicalUpdateDTO keyRegulatoryChemicalUpdateDTO) {
        return keyRegulatoryChemicalService.updateChemicals(keyRegulatoryChemicalUpdateDTO);
    }

    @ApiOperation(value = "增加企业重点监管危险化学品信息表")
    @PostMapping(value = "data/major/hazard/chemicals")
    public Result insertChemicals(@RequestBody KeyRegulatoryChemicalInsertDTO keyRegulatoryChemicalInsertDTO) {
        return keyRegulatoryChemicalService.insertChemicals(keyRegulatoryChemicalInsertDTO);
    }

    @ApiOperation(value = "删除企业重点监管危险化学品信息表")
    @DeleteMapping(value = "data/major/hazard/chemicals/{id}")
    public Result deleteChemicals(@PathVariable Long id) {
        return keyRegulatoryChemicalService.deleteChemicals(id);
    }


    @ApiOperation(value = "查询企业重点监管危险化学品信息详情")
    @GetMapping(value = "data/major/hazard/chemicals/{id}")
    public Result getChemicalById(@PathVariable Long id) {
        return keyRegulatoryChemicalService.getChemicalById(id);
    }
}